Event altKey, ctrlKey, shiftKey attribute Parsing
This article mainly analyzes the Event altKey, ctrlKey, and shiftKey attributes in detail. If you need a friend, you can refer to them and hope to help you.
Event. altKey
Function: checks whether the Alt key is held down when an event occurs.
Syntax: event. altKey
Value: true | false
Note:
If the altKey attribute is true, the Alt key is pressed and main
This article mainly analyzes the EventaltKey, ctrlKey, and shiftKey attributes in detail. If you need a friend, you can refer to them and hope to help you.
Event. altKeyFunction: checks whether the Alt key is held down when an event occurs.
Syntax: event. altKey
Value: true | false
Note:
If the altKey attribute is true, the Alt key is pressed and maintained when the event occurs. If the attribute is false, the Alt key is not pressed.The altKey attrib
This article is mainly on the event Altkey,ctrlkey,shiftkey attribute analysis of detailed analytical introduction, the need for friends can come to the reference, I hope to help you. event.altkeynbsp; function: Detects whether the ALT key was pressed when the event occurred. nbsp; Syntax: Event.altkey nbsp; Take value: TRUE | False nbsp; Description: The nbsp; Altkey property is true to indicate that the ALT key was pressed and persisted when the e
AltKey, ctrlKey, shiftKey, altkeyctrlkey
How does JavaScript ie prevent event bubbling?
The IE event is different from other standard DOM events, and the bubble mechanism of different browser events is also different.IE:Window. event. cancelBubble = true; // stop bubblingWindow. event. returnValue = false; // block the default behavior of the eventFirefox:Event. preventDefault (); // cancel the default event behavior.Event. stopPropagation (); /
Event.altkeyFunction: Detects whether the ALT key is held down when an event occurs.
Syntax: Event.altkey
Take Value: TRUE | False
Description
The Altkey property is true to indicate that the ALT key was pressed and persisted when the event occurred, and that the ALT key was not pressed.The Altkey property can be used with the mouse or keyboard, and is used to make some quick operation methods.Event.ctrlkeyFunction: Detects if the CTRL key is being held down when an event occurs.
Syntax: Ev
: event.pageX }); }); $('#box').click(function(){ $('#menulist').css('display','block'); });})
2. Select AllBy default, ctrl + A (command + A on MAC) selects the entire webpage or an editable element that obtains the focus.
This is p, this is p, This is p, this is p, This is p, this is p, This is p, this is p, This is p, this is p, This is another p, this is another p, This is another p, this is another p, This is another p, this is another p, This is another p, this is another p,
If only
parameter of the MouseEvent constructor is the event name (possible values include click, MouseDown, MouseUp, MouseOver, MouseMove, Mouseout), and the second argument is an event initialization object. The object can configure the following properties.
ScreenX, sets the horizontal coordinates of the mouse relative to the screen (but does not move the mouse), the default is 0, which is equivalent to the Mouseevent.screenx property.
ScreenY, sets the vertical coordinate of the
1. event indicates the event status, such as the element that triggers the event object, the location and status of the mouse, and the key to be pressed. The event object is valid only when an event occurs. Some Properties of the event only make sense for specific events. For example, the fromelement and toelement attributes only make sense for onmouseover and onmouseout events.
2. attributes:
Altkey, button, Member, clientx, clienty, ctrlkey
and meta for Macs) if (! Event. metakey event. ctrlkey) event. metakey = event. ctrlkey; // Add which for CLICK: 1 = left; 2 = middle; 3 = right // Note: button is not normalized, so don't use it // set the right-click in the left if (! Event. Which event. Button) event. Which = (event. Button 1? 1: (event. Button 2? 3: (event. Button 4? 2: 0); Return event ;},
Well, now let's look at the most popular
false;
}
}
// Press ctrl + enter to send
Function IsEnterAndCtrl ()
{
If (window. event. keyCode = 13 window. event. ctrlKey)
{
Send ();
Return false;
}
}
Then I use the onkeydown event of the text box to call these two functions. If the two functions do not work, I debug them and find that the events are always undefined and I am speechless, then I changed the method. I added an event parameter to the onkeydown function and defined var obj = window
The which of the event can be used to find the key code.However, when there is a combination of keys, you need to pay attention to it.For example, the ctrl + enter key uses e. ctrlKey, but the enter key code is not always 13.In ff, determine that ctrl + enter is e. ctrlKey e. which = 13In ie6, judge that ctrl + enter is e. ctrlKey e. which = 10Example:Copy code
JqueryCorrected Keyboard Events
You can pass in the event when calling the function.
Through the eventWhichYou can find the key code
However, when there is a combination of keys, you need to pay attention to it.
for example, Ctrl + enter key, E. ctrlkey but enter the key code is not always 13 now
InFFMedium JudgmentCTRL + enterYesE. ctrlkey E. Which = 13
InIE6Medium JudgmentCTR
Event objects in JavascriptWindow. evet indicates that the event represents the event state, such as the element that triggers the event object, the location and status of the mouse, and the key to be pressed.
The event object is valid only when an event occurs.
Some Properties of the event only make sense for specific events. For example, the fromelement and toelement attributes only make sense for onmouseover and onmouseout events.
Example
The following example checks whether the mouse is cli
Window. evet indicates that the event represents the event state, such as the element that triggers the event object, the location and status of the mouse, and the key to be pressed.
The event object is valid only when an event occurs.
Some Properties of the event only make sense for specific events. For example, the fromelement and toelement attributes only make sense for onmouseover and onmouseout events.
Example
The following example checks whether the mouse is clicked on the link.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.